<!--
 * @Descripttion:
 * @version:
 * @Author:
 * @Date: 2019-10-24 13:47:14
 -->
<template>
  <div>
    <dynamicForm :formConfig="someConfig"
                 v-model="someData" />
    <button @click="ssss">aaaa</button>
  </div>
</template>
<script>
import apiHome from '@/httpUtils/apiHome'
import dynamicForm from './dynamic-form'
export default {
  name: 'DynamicForm',
  components: {
    dynamicForm
  },
  data () {
    return {
      someConfig: {},
      someData: {}
    }
  },
  mounted () {
    this.setDefaultValue()
    //  假数据
    apiHome.getdynamicFormData().then(res => {
      this.someConfig = res.data
      console.log('someConfig', this.someConfig)
    })
    
  },

  methods: {
    ssss () {
      console.log("someConfig", this.someConfig)
    },
    change (formData) {
      console.log(formData)
    },
    setDefaultValue () {
      const formData = { ...this.value }
      // 设置默认值
      //   this.formConfig.formItemList.forEach(({ key, value }) => {
      //     if (formData[key] === undefined || formData[key] === null) {
      //       formData[key] = value
      //     }
      //   })
      //   this.$emit('input', formData)
    },
    handleInput (val, key) {
      // 这里element-ui没有上报event，直接就是value了
      //   this.$emit('input', { ...this.value, [key]: val })
    }
  },
}
</script>
